package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(4)
public class ATiegansanguoStrategy extends BaseGameStrategy {
    public static final String PASSWD = "diyao88";
    public static final String MAIL = "http://110.40.83.197:30288/gm/user/gmquery.php";

    @GongnengMethod(401)
    public String mail(SendItem item) {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("uid", item.uid);
        params.add("type", "mail");
        params.add("item", item.itemId);
        params.add("num", item.number);
        params.add("qu", "10001");
        params.add("checknum", PASSWD);

        String result = RestTemplateUtil.sendPostForm(MAIL, params);
        return result;
    }

    @GongnengMethod(402)
    public String largeMail(SendItem item) {
        return mail(item);
    }

    @GongnengMethod(2)
    public String pay(SendItem item) {
        System.out.println("发送充值：金额：");
        return "充值已发送，金额：";
    }

    @GongnengMethod(4)
    public String cleat(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }
}

